//
//  PartyViewController.m
//  GuoBuJiaForIphone
//
//  Created by zhangwo on 16/11/3.
//  Copyright © 2016年 GuoBuJia. All rights reserved.
//

#import "PartyViewController.h"

@interface PartyViewController ()

@end

@implementation PartyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"党建工作"];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    self.navigationItem.leftBarButtonItem = [DSXUI barButtonWithStyle:DSXBarButtonStyleBack target:self action:@selector(back)];
    
    self.webView.delegate = self;
    self.webView.scrollView.backgroundColor = [UIColor clearColor];
    
    NSString *urlString = [SITEAPI stringByAppendingFormat:@"&c=sign&a=information"];
    urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    self.request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
    
    [[DSXHttpManager sharedManager] GET:@"&c=sign&a=information&datatype=json" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
            _partyData = [responseObject objectForKey:@"data"];
            self.webView.hidden = NO;
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"%@", error);
    }];
}

- (void)back{
    if (![self.navigationController popViewControllerAnimated:YES]) {
        [self.navigationController dismissViewControllerAnimated:NO completion:nil];
        [self.indicator hide];
    }
}

#pragma mark - webView delegate
- (void)webViewDidStartLoad:(UIWebView *)webView{
    [self.indicator showViewWithTitle:nil];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [self.indicator hide];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    [[DSXUI standardUI] showPopViewWithStyle:DSXPopViewStyleError Message:error.localizedDescription];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
